package com.dreammakerteam.frameworkdemo.qzhj.service.impl;

import com.dreammakerteam.frameworkdemo.base.domain.DBaseException;
import com.dreammakerteam.frameworkdemo.base.service.impl.DBaseServiceImpl;
import com.dreammakerteam.frameworkdemo.qzhj.domain.DQzhjProductHistoryDo;
import com.dreammakerteam.frameworkdemo.qzhj.mapper.DQzhjProductHistoryMapper;
import com.dreammakerteam.frameworkdemo.qzhj.service.DQzhjProductHistoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 清真泛化产品追踪服务
 * @author xy
 * @version 0.1
 */
@Service
public class DQzhjProductHistoryServiceImpl extends DBaseServiceImpl implements DQzhjProductHistoryService {

    @Resource
    private DQzhjProductHistoryMapper dQzhjProductHistoryMapper;

    @Override
    public DQzhjProductHistoryMapper getMapper() {
        return dQzhjProductHistoryMapper;
    }

    /**
     * 获取指定产品的追踪信息
     *
     * @param prodId 产品id
     * @return 指定产品所有的追踪信息
     */
    @Override
    public DQzhjProductHistoryDo[] get(Long prodId) {
        return dQzhjProductHistoryMapper.get(prodId);
    }

    /**
     * 保存产品追踪信息
     *
     * @param dQzhjProductHistoryDo 产品追踪信息
     */
    @Override
    public void add(DQzhjProductHistoryDo dQzhjProductHistoryDo) {
        if (dQzhjProductHistoryDo == null)
            throw new DBaseException("产品信息为空");

        dQzhjProductHistoryDo.setCreateTime(new Date());
        dQzhjProductHistoryDo.insert();


        log.debug("保存产品追踪信息" + dQzhjProductHistoryDo);
    }
}
